home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 27.zip
/
BS1 part 27
/
ImageMaster_d3.adf
/
piarc.lzh.parta
/
bmp.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-04-14
|
5KB
|
209 lines
/* ARexx BMP */
parse arg var1
/*
* BMP.rexx - MS-Windows (and OS/2) bitmap image load and save.
*
* If you encounter a .BMP file we do not read, sent it to us (we suggest
* you use the Black Belt Bulletin Board at 1-406-367 2227) with an
* explanation and we will endeavor to extend our loader to handle it.
*
* Written by: Black Belt Systems Technical Development
* December 23rd, 1992
* Last update: March 25th, 1993
* Revision: 1.03
* For: Black Belt Systems image processing series IM, IM F/c, and IP.
*
* Modifications:
* 1.00 23 Dec 1992 (BC) Initial release.
* 1.01 5 Jan 1993 (BC) Odd width bitmaps were not saved 32-bit
* alligned.
* 1.02 3 Feb 1993 (BC) Fixed enforcer hits
* 1.03 25 Mar 1993 (BC) Did not fail properly if not enough memory.
*
*/
call pragma('stack',20000);
/*
* open rexxsupport.library -- needed for some functions
*/
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then do
/* everything's ok */
end;
else do
say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
say 'Cannot operate script without this library - sorry!';
exit 10;
end;
end;
prtnme = 'IM_Port';
cmdpath = 'cmpi:';
/*
* Get the file name parts
*/
prevpath = 'ram:';
if show('C',rawpath) = 1 then do
prevpath = getclip(rawpath);
end;
prevname = 'image';
if show('C',rawname) = 1 then do
prevname = getclip(rawname);
end;
prevext = '.BMP';
if show('C',rawext) = 1 then do
prevext = getclip(rawext);
end;
address(prtnme);
'autoredraw 0';
if var1 = 'load' then do
loadquestion = 0
end
else if var1 = 'save' then do
loadquestion = 1
end
else do
options results;
'gadgets "Load .BMP","Image","Save .BMP","Image"';
loadquestion = result-1;
options;
end
if loadquestion < 0 then do
address(prtnme);
'tofront';
exit 0;
end
if loadquestion = 0 then do
options results;
'filerequest "'||prevpath||'" "'||prevname||'" "'||prevext||'" '||'"Load .BMP"';
bmpfile = result;
options;
call checkfile(bmpfile);
end
if loadquestion = 1 then do
options results;
'filerequest "'||prevpath||'" "'||prevname||'" "'||prevext||'" '||'"Save .BMP"';
bmpfile = result;
options;
call checkfile(bmpfile);
/* Could put compression question Here !! */
end
options results;
'jackin';
jack = result;
options;
address command cmdpath||'bmp '||jack||' '||loadquestion||' "'||bmpfile||'" '||prevname||' '||compression;
address(prtnme);
'autoredraw 1';
exit 0;
checkfile:
arg thefile;
if thefile = 'FR_CANCELLED' then do
address(prtnme);
'tofront';
exit 0;
end;
prevpath = gimmepath(thefile);
call setclip(rawpath,prevpath);
prevname = gimmename(thefile);
call setclip(rawname,prevname);
prevext = gimmeext(thefile);
call setclip(rawext,prevext);
return;
end
/*
* gimmepath
*
* This takes the provided argument and sucks the path out of it, then
* returns that path to the caller, sans file name.
*/
gimmepath:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
gxpath = left(fullnamegx,seploc);
return(gxpath);
end
gimmename:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(".",fullnamegx) - 2;
if extpos > seploc then do
gxname = substr(fullnamegx,seploc+1,extpos-seploc+1);
end;
else do
gxname = substr(fullnamegx,seploc+1);
end;
return(gxname);
end
gimmeext:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(fullnamegx,'.');
if extpos > seploc then do
gxext = substr(fullnamegx,extpos+1);
end
else do
gxext = '';
end
return(gxext);
end